/***************************************************************************
 *   Copyright (C) 2007 by Eduardo Robles Elvira   *
 *   edulix@gmail.com   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#include <QtGui>
#include "konntrack4.h"
#include "konntrackwidget.h"

#include <QTextEdit>
#include <QTextStream>
#include <QCloseEvent>
#include <QFileDialog>

using namespace std;

konntrack4::konntrack4()
{
	kw = new KonntrackWidget(this);
	
	
	setCentralWidget(kw);
	
	createActions();
	createMenus();
	createToolBars();
	createStatusBar();
	
	readSettings();
}

void konntrack4::closeEvent(QCloseEvent */*event*/)
{
}

void konntrack4::about()
{
      QMessageBox::about(this, tr("About Application"),
            tr("Software licensed under GPL v2 or superior\n"
            "Copyright (c) 2007\n"
            "Eduardo Robles Elvira <edulix@gmail.com>"));
}

void konntrack4::createActions()
{
      newAct = new QAction(QIcon(":/filenew.xpm"), tr("&New"), this);
      newAct->setShortcut(tr("Ctrl+N"));
      newAct->setStatusTip(tr("Create a new file"));

      exitAct = new QAction(tr("E&xit"), this);
      exitAct->setShortcut(tr("Ctrl+Q"));
      exitAct->setStatusTip(tr("Exit the application"));
      connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
      
      aboutAct = new QAction(tr("&About"), this);
      aboutAct->setStatusTip(tr("Show the application's About box"));
      connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
}

void konntrack4::createMenus()
{
      fileMenu = menuBar()->addMenu(tr("&File"));
      fileMenu->addAction(newAct);
      fileMenu->addSeparator();
      fileMenu->addAction(exitAct);

      editMenu = menuBar()->addMenu(tr("&Edit"));

      menuBar()->addSeparator();

      helpMenu = menuBar()->addMenu(tr("&Help"));
      helpMenu->addAction(aboutAct);
}

void konntrack4::createToolBars()
{
//       fileToolBar = addToolBar(tr("File"));
//       fileToolBar->addAction(newAct);
}

void konntrack4::createStatusBar()
{
      statusBar()->showMessage(tr("Ready"));
}

void konntrack4::readSettings()
{
      QSettings settings("Trolltech", "Application Example");
      QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
      QSize size = settings.value("size", QSize(800, 600)).toSize();
      resize(size);
      move(pos);
}

void konntrack4::writeSettings()
{
	QSettings settings("Konntrack", "Konntrack");
	settings.setValue("pos", pos());
	settings.setValue("size", size());
}

QString konntrack4::strippedName(const QString &fullFileName)
{
      return QFileInfo(fullFileName).fileName();
}

konntrack4::~konntrack4()
{

}

